home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_020 / setmouse2 / setmouse.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  66 lines

  1. /*********************************************************************/
  2. /*                                                                   */
  3. /*  ProgramName:   SetMouse                                          */
  4. /*                                                                   */
  5. /*  Purpose:       To indicate that the mouse is connected to a      */
  6. /*                 specific game port                                */
  7. /*                                                                   */
  8. /*  Programmer:    Kodiak, Commodore-Amiga Inc.                      */
  9. /*                                                                   */
  10. /*  PlagiarPolicy: You got it, use it however you want.              */
  11. /*                                                                   */
  12. /*********************************************************************/
  13.  
  14. #include <exec/types.h>
  15. #include <exec/nodes.h>
  16. #include <exec/lists.h>
  17. #include <exec/ports.h>
  18. #include <exec/io.h>
  19.  
  20. #include <devices/input.h>
  21.  
  22. struct IOStdReq ior;
  23. struct MsgPort  iorp;
  24.  
  25. main(argc, argv)
  26. int argc;
  27. char *argv[];
  28. {
  29.     UBYTE port;
  30.  
  31.     /**/
  32.     /* this is not intended to be a tutorial about how to get arguments
  33.     /* from either the CLI or workbench, so I'll just hard code this to
  34.     /* set the mouse port to port '2' (the right mouse port).  Assign
  35.     /* the value port = 0; to set port '1' (the left mouse port).
  36.     /**/
  37.     port = 1;
  38.  
  39.     /* Open the input device */
  40.     if (OpenDevice("input.device", 0, &ior, 0) != 0)
  41.     {
  42.     exit(20);
  43.     }
  44.  
  45.     /* set up the message port in the I/O request */
  46.     iorp.mp_Node.ln_Type = NT_MSGPORT;
  47.     iorp.mp_Flags = 0;
  48.     if ((iorp.mp_SigBit = AllocSignal(-1)) < 0) {
  49.     CloseDevice(&ior);
  50.     exit(20);
  51.     }
  52.     iorp.mp_SigTask = (struct Task *) FindTask((char *) NULL);
  53.     NewList(&iorp.mp_MsgList);
  54.     ior.io_Message.mn_ReplyPort = &iorp;
  55.  
  56.     /* initiate the I/O request to change the mouse port */
  57.     ior.io_Command = IND_SETMPORT;
  58.     ior.io_Data = &port;
  59.     ior.io_Length = 1;
  60.     DoIO(&ior);
  61.  
  62.     /* clean up */
  63.     CloseDevice(&ior);
  64.     FreeSignal(iorp.mp_SigBit);
  65. }
  66.